var appInstance = getApp();
var pageData    = {
  data: {
    add1:[true],
    add2:[],
    navbar: ['全部', '行业', '城市'],  
    currentTab: 0, 
  },
  app_title: '石雕小程序',
  app_description: '加油!',
  page_router: 'page10010',
  page_router1: '10010',
  onLoad: function (e) {
    var that =this;
     },
  onShareAppMessage: function(){
    var pageRouter = this.page_router;
    var pageRouter1 = this.page_router1;
    return {
      title: this.app_title || '产品设计',
      desc: this.app_description || '',
      path: '/pages/'+pageRouter+'/'+pageRouter1
    }
  },
  onShow: function(){ 
  },
  tapDelete:function(e){
    var that = this;
    console.log(e);
    var tapeven = e.currentTarget.id;
    wx.showModal({
      title: '提示',
      content: '确认删除图片？',
      success: function(res) {
        if (res.confirm) {
          if(tapeven=='add'){
          var add = [true];
          that.setData({add1:add})
          }else{
          var add = that.data.add2;
          console.log(tapeven)
          add.splice(tapeven,1);
          console.log(add)
          that.setData({add2:add}) 
          }
        }
      }
    })
  },
  tapInnerLinkHandler:function(e){
    var that = this;
    var tapeven = e.currentTarget.id;
    console.log(e);
    if(tapeven =='add1'||tapeven =='add2'){
      wx.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'],
        sourceType: ['album'],
        success: function (res) { 
          console.log(res);       
          var tempFilePath = res.tempFilePaths[0];
          console.log(tempFilePath)
          if(tapeven=='add1'){
          var add = [false,tempFilePath];
            that.setData({add1:add})
            }else{
              var add =that.data.add2;add.push(tempFilePath);
              console.log(add)
              that.setData({add2:add})}
          //uploadfile
        },
        fail:function(res){
          console.log(res);
        },
        complete:function(res){
          console.log(res);
        }
      })
    }else{
      wx.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'],
        sourceType: ['camera'],
        success: function (res) {        
          var tempFilePaths = res.tempFilePaths;
          var add = [false,tempFilePaths];
          if(tapeven=='add1'){that.setData({add1:add})}else{that.setData({add2:add})}
          //uploadfile
        }
      })
    }
 }
    // var tab = JSON.parse(tapeven);
    // console.log(tab.inner_page_link);
  
};
Page(pageData);